﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;

public class GameMgr : MonoBehaviour
{
    public GameObject TileMaps;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        //if (Input.GetMouseButtonUp(0)) {
        //    //var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        //    var wPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        //    var cellPos = TileMaps.GetComponent<Tilemap>().WorldToCell(wPos);
        //    if (TileMaps.GetComponent<Tilemap>().HasTile(cellPos)) {
        //        TileMaps.GetComponent<Tilemap>().SetColor(cellPos,Color.red);
        //    }
        //}
        //if (Input.GetMouseButtonUp(0)) {
        //    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        //    //由正确的方向得到屏幕中tile所在的位置
        //    var tilemap = TileMaps.GetComponent<Tilemap>();
        //    Vector3Int vector = tilemap.WorldToCell(ray.GetPoint(-ray.origin.z / ray.direction.z));
        //    //对该位置进行点击测试
        //    if (tilemap.HasTile(vector)) {
        //        Debug.Log("瓦片原颜色 ！" + tilemap.GetColor(vector)+" "+ tilemap.GetTileFlags(vector));

        //        tilemap.SetTileFlags(vector, TileFlags.None);

        //        tilemap.SetColor(vector,new Color(0.5f,0.5f,0.5f,1f));


        //        Debug.Log("瓦片改变颜色！"+ tilemap.GetColor(vector));
        //        //Debug.DrawLine();
        //    }
                
        //}
        
    }
}
